package com.neborosoft.FlyingDog.android.playing.modes;

import android.app.Activity;
import android.os.Parcelable;
import android.widget.AbsListView;
import com.neborosoft.FlyingDog.android.gui.adapters.listview.SongsPlayListAdapter;
import com.neborosoft.android.gui.wrappers.ListViewSwitcher;
import com.neborosoft.lib.API_8.Collections;

import java.util.Comparator;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: CM
 * Date: 01.12.12
 * Time: 18:20
 * To change this template use File | Settings | File Templates.
 */
public abstract class PlayingMode{
    private ListViewSwitcher listViewSwitcher;
    private Activity activity;

    public ListViewSwitcher getListViewSwitcher() {
        return listViewSwitcher;
    }

    public abstract void showInListView(boolean restoreState);

    public PlayingMode(Activity activity, ListViewSwitcher listViewSwitcher) {
        this.listViewSwitcher = listViewSwitcher;
        this.activity = activity;
    }

    public final Object search(String query){
        return performSearch(query);
    }


    protected final AbsListView getListView(){
        ListViewSwitcher listViewSwitcher = getListViewSwitcher();
        return listViewSwitcher.getListView();
    }

    public final Parcelable getListViewState(){
        AbsListView listView = getListView();
        return listView.onSaveInstanceState();
    }

    protected abstract Object performSearch(String query);
    public abstract void onSearchFinished(Object searchResult);
    public abstract List<String> getSearchSuggestions(String query);
    protected abstract SongsPlayListAdapter getSongsPlayListAdapter();
    public Map<Integer, Comparator> getSortingComparatorsForMenuItemIdes(){
        return Collections.emptyMap();
    }
    public abstract Object getState();
    public abstract void restoreState(Object state);

    public void onSkipSearch() {

    }

    public void onAnotherModeSelected(){

    }

    public boolean isSearchAllowed(){
        return true;
    }

    public final Activity getActivity() {
        return activity;
    }
}
